//
// Created by Administrator on 2016/12/9.
//

#ifndef PROJECT_RUBIK_H
#define PROJECT_RUBIK_H

#include "Cube.h"
#include <random>

class Rubik {
public:
    static uint16_t Dimen;
    static std::default_random_engine DefaultRandomEngine;

    float PI = 3.14159265358979323846264338327950288;
    float PIm2 = PI * 2;
    float PId2 = PI / 2;
    float PId4 = PI / 4;
    float autoRotateSpeed = PI/1400;//180 degree per 1400ms

    Rubik(btDynamicsWorld *dynamicsWorld, btCollisionShape *boxCollisionShape, float size, ZainGL::Model *model);

    virtual ~Rubik();

    std::vector<Cube *> mCubes;

    glm::vec3 mCenter;
    glm::mat4 mTransByMCenter;

    void onTick(float deltaTime);

    float autoRotateSliceRadian=0;

    FACE mClickedFace=NONE;
    glm::vec3 mSliceCenter,mRotateVector;
    std::vector<Cube *> mSameSliceCubes;
    void findSameSliceCubes(Cube *baseCube, AXES rotateAxesPivot);
    void rotateSlice(float radian, bool bFinalRotation= false);

    int32_t mAutoMessCount=0;
    bool bAutoMessing= false;
    float mManualRotatedRadian=0;

    bool checkWin();

    bool bWin=false;
};


#endif //PROJECT_RUBIK_H
